import os
txtcount=0
jpgcount=0
docxcount=0
avicount=0
dircount=0
dirall=[]
fileall=[]
dirpath='d:\\360downloads'
all=os.walk(dirpath)
for each in all:
    fileall.append(each[2])
    dirall.append(each[0])
for eachfileall in fileall:
    for n in range(len(eachfileall)):
        txtcount+= eachfileall[n].count('.txt')
        jpgcount += eachfileall[n].count('.JPG')
        jpgcount += eachfileall[n].count('.jpg')
        avicount += eachfileall[n].count('.avi')
        docxcount += eachfileall[n].count('.docx')
    else:
        continue
for eachdir in dirall:
    if os.path.isdir(eachdir):
        # print(eachdir)
        dircount+=1
    else:
        continue
print('该文件夹下共有类型为【.txt】的文件%d个'%txtcount)
print('该文件夹下共有类型为【.jpg】的文件%d个'%jpgcount)
print('该文件夹下共有类型为【.avi】的文件%d个'%avicount)
print('该文件夹下共有类型为【.docx】的文件%d个'%docxcount)
print('该文件夹下共有类型为【文件夹】的文件%d个'%(dircount-1))
